#!/bin/bash 


#Copyright (C) 2008 Victor Manuel Sanchez Cartagena, Juan Antonio Perez Ortiz
#
#This file is part of ANTLRArbol.
#
#ANTLRArbol is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
#
#ANTLRArbol is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. 




############
FILE=Prefix.g
FIRST_RULE=prog
#############



echo $FILE >tmp
cut -d. -f1 tmp > tmp2
GRAMMAR_NAME=`cat tmp2`
rm tmp tmp2

COUNT=0

function execute_test(){
	java org.ANTLRArbol.bin.GenerateMain $GRAMMAR_NAME $FIRST_RULE dot$2
	java org.ANTLRArbol.bin.CreateTree $1 $FILE
	javac *.java
	java Main$GRAMMAR_NAME input$2
	dot -Tpng -otree$2.png dot$2
}


exec 0< options
while read -r LINE
do
	execute_test "$LINE" $COUNT
	let "COUNT=COUNT+1"
done 
